package demo01;

import java.io.IOException;
import java.io.InputStream;
import java.net.Socket;
import java.nio.charset.StandardCharsets;
import java.util.Scanner;

public class SocketDemo {
    public static void main(String[] args) {
        try (Socket socket = new Socket("bbs.newsmth.net", 23)) {
            socket.setSoTimeout(10000);
            InputStream is = socket.getInputStream();
            Scanner scanner = new Scanner(is, StandardCharsets.UTF_8);

            while (scanner.hasNextLine()) {
                String line = scanner.nextLine();
                System.out.println(line);
            }

        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
